<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>watch监听</title>
</head>
<body>
<script src="../js/vue.js"></script>
<div id="app">
    {{firstname}}
    <input type="text" v-model="firstname">
</div>
</div>

<script>
    var app = new Vue({
        el: "#app",   //element:元素
        data: {        //data:数据 用来vue实例对象绑定一系列数据
            msg: "watch监听",
            firstname: "双向绑定",
        },
        methods: {},
        watch: {// 使用这个属性,可以监听data中指定的数据变化.然后出发watch中对应的函数处理
            firstname() {
                alert("监听到了")
            }
        },
        computed: {}
    });
</script>
</body>
</html>